package com.company.project.builder.wx.outxml;

import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMusicMessage;

/**
 * @author xsk
 */
public class MusicBuilder {

    /**
     *
     * @param title 可选
     * @param description 可选
     * @param musicUrl 可选
     * @param hQMusicUrl 可选
     * @param thumbMediaId
     * @param wxMessage
     * @return
     */
    public WxMpXmlOutMessage build(String title , String description , String musicUrl ,
                                   String hQMusicUrl , String thumbMediaId , WxMpXmlMessage wxMessage) {

        me.chanjar.weixin.mp.builder.outxml.MusicBuilder mb  = WxMpXmlOutMessage.MUSIC()
                .thumbMediaId(thumbMediaId)
                .fromUser(wxMessage.getToUser())
                .toUser(wxMessage.getFromUser());

        if(title != null)
            mb.title(title);
        if(description != null)
            mb.description(description);
        if(musicUrl != null)
            mb.musicUrl(musicUrl);
        if(hQMusicUrl != null)
            mb.hqMusicUrl(hQMusicUrl);

        WxMpXmlOutMusicMessage m = mb.build();

        return m;
    }

}
